/*
Uses user_first_cholesterol_dates.dta created in S1 - Create Quarterly Drug Panel.do and panel_enrolid_2003_2012 created in S3 - Create User Characteristics and Lists
*/


clear
use user_first_cholesterol_dates

//hist first_date
rename first_use_date first_date
gen month = mofd(first_date)

gen people = 1
collapse (count) people, by(month)

gen date = dofm(month)
gen date_copy = date
format date %td
scatter people date, xline(13545) xline(15650) xline(15937) xline(16281) xline(16975) xline(18961) xtitle("First Prescription Date") ytitle("New Users")

graph save "unbalanced_smoothness_check", replace
graph export unbalanced_smoothness_check.pdf, replace




clear
use user_first_cholesterol_dates 


merge m:1 enrolid using "panel_enrolid_2003_2012"
keep if _merge == 3
drop _merge

keep if first_use_date >= mdy(6,1,2003)

//hist first_date
rename first_use_date first_date
gen month = mofd(first_date)

gen people = 1
collapse (count) people, by(month)

gen date = dofm(month)
gen date_copy = date
format date %td
scatter people date, xline(15937) xline(16281) xline(16975) xline(18961) xtitle("First Prescription Date") ytitle("New Users")


graph save "balanced_smoothness_check", replace
graph export balanced_smoothness_check.pdf, replace
